class Solution:
    def jump(self, nums: list) -> int:
        def func(nums, index, cache):
            if index in cache:
                return cache[index]
            if index == len(nums) - 1:
                return 0
            res = 2**31
            for i in range(index + 1, len(nums)):
                if i <= index + nums[index]:
                    res = min(func(nums, i, cache) + 1, res)
            cache[index] = res
            return res

        return func(nums, 0, {})
